#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int a, b, c, i, x, y, z, sum;
	char ch;
	cin >> x >> y >> z;
	sum = x + y + z;
	a = min(min(x, y), z);
	c = max(max(x, y), z);
	b = sum - a - c;
	for (i = 1; i <= 3; i++)
	{
		cin >> ch;
		if (ch == 'A') cout << a << ' ';
		if (ch == 'B') cout << b << ' ';
		if (ch == 'C') cout << c << ' ';
	}
	return 0;
	
}